<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>用户管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" th:href="@{/layuiadmin/layui/css/layui.css}" media="all">
</head>
<body>
<div id="user-edit-form" class="layui-form" lay-filter="user-edit-form" style="padding: 20px 30px 0 0;">
    <input type="hidden" name="id" id="userId"/>
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input disabled="" type="text" name="username" id="username" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="gender" value="1" title="男">
            <input type="radio" name="gender" value="0" title="女">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号码</label>
        <div class="layui-input-block">
            <input type="text" name="mobile" id="mobile" lay-verify="required|phone" placeholder="请输入号码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名</label>
        <div class="layui-input-block">
            <input type="text" name="realName" id="realName" lay-verify="required" placeholder="请输入真实姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="text" name="email" id="email" lay-verify="required|email" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-block">
            <select name="roles" xm-select="roleSelect" xm-select-direction="down" xm-select-height="36px">
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="user-edit-submit" id="user-edit-submit" value="确认">
    </div>
</div>
<script th:src="@{/layuiadmin/layui/layui.js}" charset="utf-8"></script>
<script>
layui.config({
    base: '/layuiadmin/' //静态资源所在路径
}).extend({
    formSelects: 'res/js/component/formSelects-v4'
}).use(['formSelects'],
function() {
    var formSelects = layui.formSelects;
    formSelects.data('roleSelect', 'server', {
        url: '/admin/role/inquiry/select'
    });
});
//初始化
function initData(result) {
    //多选下拉框
    ;!function() {
        var form = layui.form;
        var formSelects = layui.formSelects;
        var $ = layui.jquery;
        var roleIds = new Array();
        $.each(result.dataList,
        function(i, item) {
            roleIds.push(item.id);
        });
        form.val("user-edit-form", {
            "id": result.id,
            "username": result.username,
            "mobile": result.mobile,
            "realName": result.realName,
            "email": result.email
        });
        $("input[name=gender][value=0]").attr("checked", result.gender == 0 ? true: false);
        $("input[name=gender][value=1]").attr("checked", result.gender == 1 ? true: false);
        formSelects.value('roleSelect', roleIds);
        form.render();
    }();
}
</script>
</body>
</html>